﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="ThietBiSo.LinQDB" %>
<%@ Import Namespace="ThietBiSo.Models" %>
<!DOCTYPE html>
<html>
<head runat="server">
    <title>PopUpUpload</title>
    <script src="<%= Url.Content("~/Content/jsAdmin/webservice/jquery.js")%>" type="text/javascript"></script>
    <script src="<%= Url.Content("~/Content/jsAdmin/webservice/jscontroller.js")%>" type="text/javascript"></script>
    <script src="<%= Url.Content("~/ckeditor/ckeditor.js") %>" type="text/javascript"></script>
    <script src="<%= Url.Content("~/ckfinder/ckfinder.js")%>" type="text/javascript"></script>

    <link href="../../Content/cssAdmin/admin.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function submitForm() {
            if (checkForm()) {
                document.forms[0].submit();
            }
        }

        function checkForm() {
            var flag = true;
            var F = document.forms[0];
            var HinhAnh = document.getElementById("HinhAnh").value;

            if (HinhAnh == null || HinhAnh == "") {
                alert("Chưa chọn hình ảnh");
                F.HinhAnh.focus();
                flag = false;

            }
            return flag;
        }
        function URL() {
            var str = this.Url.RouteUrl(this.ViewContext.RouteData.Values);
            alert(str);
        }
    </script>
</head>
<body>
    <div style="float: left; margin-top:10px; margin-left:130px; margin-bottom:10px;">
        <% using (Html.BeginForm("PopUpUpload", "SanPham", FormMethod.Post, new { @enctype = "multipart/form-data" }))
           { %>
        <%: Html.ValidationSummary(true)%>
        <%:Html.TextBox("HinhAnh")%>
        <input type="button" value="Chọn..." id="btnSelectImg" name="btnSelectImg" />
        <script type="text/javascript">
            $(document).ready(function () {
                $("#btnSelectImg").click(function () {
                    var finder = new CKFinder();
                    finder.selectActionFunction = function (fileUrl) {
                        $('#HinhAnh').val(fileUrl);
                    };
                    finder.popup();
                });
            });
        </script>
        <input type="button" value="Thêm" class="btn" onclick="submitForm();" />
        <%:Html.Hidden("MaSP", ViewData["urlid"])%>
        <%} %>
    </div>
    <div style="float: left;margin-left:20px; clear:both">
        <table width="600" cellpadding="2" cellspacing="0" border="0">
            <tr>
                <td colspan="2">
                    <table id="bang_admin" class="tbl colorize" width="600" border="0">
                        <tbody>
                            <tr>
                                <th align="center" width="20px">
                                    TT
                                </th>
                                <th align="center" width="50">
                                    Hinh
                                </th>
                                <th align="center" width="200">
                                    Url Images
                                </th>
                                <th width="10">
                                    Hiển<br />
                                    thị
                                </th>
                                <th align="right" width="30">
                                    Xóa
                                </th>
                            </tr>
                        </tbody>
                        <tbody>
                            <% foreach (ImagesSanPham item in (List<ImagesSanPham>)ViewData["listImages"])
                               {               
                            %>
                            <tr class="tb_hienthi">
                                <td align="center" valign="middle">
                                    <input type="text" disabled="disabled" style="width: 20px"class="orderbox"
                                        value="<%:item.ThuTu %>" maxlength="4" id="thutu" />&nbsp;
                                </td>
                                <td align="center" valign="middle">
                                    <img src="<%:item.UrlImages %>" alt="" width="100px;" height="50px;" />
                                </td>
                                <td align="left">
                                    <%: item.UrlImages%>
                                </td>
                                <td align="center">
                                    <%if (item.HienThi == false)
                                      {
                                    %>
                                    <a href="javascript:HienThi_Images(<%:item.ID%>);">
                                        <input type="checkbox" />
                                    </a>
                                    <%}
                                      else
                                      {%>
                                    <a href="javascript:HienThi_Images(<%:item.ID%>);">
                                        <input type="checkbox" checked="checked" /></a>
                                    <%} %>
                                </td>
                                <td align="center">
                                    <a href="javascript:Delete_Images(<%:item.ID %>);">
                                        <img src="../../Content/imagesAdmin/images/pic_trash.gif" alt="" /></a>
                                </td>
                            </tr>
                            <% } %>
                        </tbody>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
